package nl.borchef.map_2d_game;

import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;

public class game_activity extends Activity {
	/** Called when the activity is first created. */

	// members
	private game_view mo_game_view = null;
	private float mf_back_ground_volume = 0.001f;
	private  MediaPlayer mo_music_player = null;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        //Log.d(this.getClass().getName(), "class created");
		// turn off the window's title bar
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		if( mo_music_player == null ){
			AudioManager audio_manager = (AudioManager) getSystemService(AUDIO_SERVICE);
			float volume = audio_manager.getStreamVolume( AudioManager.STREAM_MUSIC );
			volume *= mf_back_ground_volume;
			mo_music_player = MediaPlayer.create(this, R.raw.intro_sound );
			mo_music_player.setVolume( volume, volume );
			mo_music_player.setLooping(true);
			mo_music_player.start();
		}
		mo_game_view = new game_view(this);
		setContentView(mo_game_view);
	}

	@Override
	protected void onDestroy() {
		if( mo_music_player != null ){
			mo_music_player.stop();
	    	mo_music_player.release();
			mo_music_player = null;
		}
		super.onDestroy();
	}
}